package com.atguigu.springboot.controller;

import com.atguigu.springboot.exception.UserNotExistException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Map;

//@ResponseBody 在类上,表示该类中的所有方法返回数据都是直接返回给浏览器的json串

@Controller
public class HelloController {

    @ResponseBody
    @RequestMapping("hello")
    public String hello(String user){
        if ("aaa".equals(user)){
            throw new UserNotExistException();
        }
        return "hello world quick!";
    }

    @RequestMapping("success")
    public String success(Map<String,Object> map){
        map.put("hello","<h1>hello\nworld</h1>");
        map.put("list", Arrays.asList("张三","李四","王五"));
        return "success";
    }
}
